package com.meirimoney.app;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import com.meirimoney.task.SignInThreadRunnable;

public class BaseAccount extends BaseActivity
{
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		if (!this.getUser().getLoginStatus())
		{
			new Thread(new SignInThreadRunnable(this, this.signInHandle))
					.start();
		}
	}

	
	/**
	 * 用户登录成功之后调用该方法
	 */
	public void done()
	{
		//供客户端重载
	}
	
	private void proxyDone()
	{
		this.done();
	}

	private Handler signInHandle = new Handler()
	{
		@Override
		public void handleMessage(Message msg)
		{
			Bundle bd = msg.getData();
			Integer status = bd.getInt("status");
			if (status == SignInThreadRunnable.NETWORKABERRANT)
			{
				showToastMessage("网络异常，登录失败！");
			} else if (status == SignInThreadRunnable.SYSTEMABERRANT)
			{
				showToastMessage("系统异常，登录失败！");
			} else if (status == SignInThreadRunnable.NORMAL)
			{
				getUser().setLoginStatus(true);
				proxyDone();
			}
		}
	};
}
